home *** CD-ROM | disk | FTP | other *** search
/ Visual Cafe 3 / Visual Cafe 3.ISO / Vcafe / Main.bin / JChartBeanInfo.java < prev    next >
Text File  |  1998-10-28  |  13KB  |  305 lines

  1. package com.symantec.itools.swing;
  2.  
  3. import java.beans.*;
  4. import java.util.ResourceBundle;
  5. import com.symantec.itools.swing.DesignTimeResourceBundle;
  6. import com.symantec.itools.swing.beans.BeanDescriptorAttributes;
  7. import com.symantec.itools.beans.*;
  8. import com.symantec.itools.beans.HelperBeanInfo;
  9. import com.symantec.itools.vcafe.beans.*;
  10. import com.symantec.itools.vcafe.beans.ActionDescriptor;
  11. import com.symantec.itools.vcafe.beans.MethodDescriptorAttributes;
  12.  
  13. public final class JChartBeanInfo
  14.     extends com.symantec.itools.beans.HelperBeanInfo
  15. {
  16.     public JChartBeanInfo()
  17.     {
  18.         setInheritSuperBeanInfo(true);
  19.  
  20.         ResourceBundle resources = ResourceBundle.getBundle("com.symantec.itools.swing.DesignTimeResourceBundle");
  21.         String folderName = resources.getString(DesignTimeResourceBundle.SWING_ADDITIONS_FOLDER_TOOLBAR_KEY);
  22.         setComponentLibraryFolder(folderName);
  23.         setToolbarFolder(folderName);
  24.  
  25.         setWinHelpKey(m_WinHelpID);
  26.         setIsContainer( false );
  27.  
  28.         set16x16ColorIconName("JChart.gif");
  29.     }
  30.  
  31.     protected Class getBeanClass()
  32.     {
  33.         return JChart.class;
  34.     }
  35.  
  36.     public PropertyDescriptor[] getPropertyDescriptors()
  37.     {
  38.         try
  39.         {
  40.             final Class beanClass = getBeanClass();
  41.  
  42.             PropertyDescriptor model = new PropertyDescriptor("model", beanClass); 
  43.             model.setValue(PropertyDescriptorAttributes.WIN_HELP_ATTRIBUTE, new Integer(PropertyHelpIDs.JCHART_MODEL_HELP_ID));
  44.             
  45.             PropertyDescriptor graphStylePD = new PropertyDescriptor("style", beanClass);
  46.             graphStylePD.setPropertyEditorClass(GraphStylePropertyEditor.class);
  47.             graphStylePD.setValue(PropertyDescriptorAttributes.WIN_HELP_ATTRIBUTE, new Integer(PropertyHelpIDs.JCHART_STYLE_HELP_ID));
  48.             
  49.             PropertyDescriptor showLegend = new PropertyDescriptor("showLegend", beanClass);
  50.             showLegend.setValue(PropertyDescriptorAttributes.WIN_HELP_ATTRIBUTE, new Integer(PropertyHelpIDs.JCHART_SHOW_LEGEND_HELP_ID));
  51.             
  52.             PropertyDescriptor showGrid = new PropertyDescriptor("showGrid", beanClass);
  53.             showGrid.setValue(PropertyDescriptorAttributes.WIN_HELP_ATTRIBUTE, new Integer(PropertyHelpIDs.JCHART_SHOW_GRID_HELP_ID));
  54.             
  55.             PropertyDescriptor title = new PropertyDescriptor("title", beanClass);
  56.             title.setValue(PropertyDescriptorAttributes.WIN_HELP_ATTRIBUTE, new Integer(PropertyHelpIDs.JCHART_TITLE_HELP_ID));
  57.             
  58.             PropertyDescriptor precision = new PropertyDescriptor("precision", beanClass );
  59.             precision.setValue(PropertyDescriptorAttributes.WIN_HELP_ATTRIBUTE, new Integer(PropertyHelpIDs.JCHART_PRECISION_HELP_ID));
  60.             
  61.             PropertyDescriptor numYTicks = new PropertyDescriptor("numYTicks", beanClass);
  62.             numYTicks.setValue(PropertyDescriptorAttributes.WIN_HELP_ATTRIBUTE, new Integer(PropertyHelpIDs.JCHART_NUM_YTICKS_HELP_ID));
  63.             
  64.             PropertyDescriptor yAxisMin = new PropertyDescriptor("yAxisMin", beanClass);
  65.             yAxisMin.setValue(PropertyDescriptorAttributes.WIN_HELP_ATTRIBUTE, new Integer(PropertyHelpIDs.JCHART_YAXIS_MIN_HELP_ID));
  66.             
  67.             PropertyDescriptor yAxisMax = new PropertyDescriptor("yAxisMax", beanClass);
  68.             yAxisMax.setValue(PropertyDescriptorAttributes.WIN_HELP_ATTRIBUTE, new Integer(PropertyHelpIDs.JCHART_YAXIS_MAX_HELP_ID));
  69.             
  70.             PropertyDescriptor[] rv = {   
  71.                     model,
  72.                     graphStylePD,
  73.                     showLegend,
  74.                     showGrid,
  75.                     title,
  76.                     precision,
  77.                     numYTicks,
  78.                     yAxisMin,
  79.                     yAxisMax };
  80.                     
  81.             return rv;
  82.         }
  83.         catch(IntrospectionException e)
  84.         {
  85.             e.printStackTrace();
  86.         }
  87.  
  88.         //Error, return no properties
  89.         return new PropertyDescriptor[0];
  90.     }
  91.  
  92.      /**
  93.      * Gets an array of descriptions of the methods used for "connections" by
  94.      * Visual CafΘs Interaction Wizard.
  95.      * Included in each method description is a CONNECTIONS ActionDescriptor.
  96.      * @return method descriptions for this bean
  97.      * @see com.symantec.itools.vcafe.beans.ActionDescriptor
  98.      */
  99.  
  100.     public MethodDescriptor[] getMethodDescriptors() {
  101.         Class[] args;
  102.         ActionDescriptor connection;
  103.         java.util.Vector connections;
  104.         java.util.Vector md = new java.util.Vector();
  105.         ResourceBundle conn = ResourceBundle.getBundle("com.symantec.itools.swing.JChartResourceBundle");
  106.  
  107.         try{
  108.             args = null;
  109.             MethodDescriptor getModel = new MethodDescriptor(beanClass.getMethod("getModel", args));
  110.  
  111.             connections = new java.util.Vector();
  112.             connection = new ActionDescriptor("output", "TableModel", "",
  113.                                     "%name%.getModel()",
  114.                                     conn.getString(JChartResourceBundle.JCHART_GET_MODEL_CONNNECTION_KEY));
  115.             connections.addElement(connection);
  116.  
  117.             getModel.setValue(MethodDescriptorAttributes.ACTION_ATTRIBUTE, connections);
  118.             md.addElement(getModel);
  119.         } catch (Exception e) { throw new Error("getModel:: " + e.toString()); }
  120.  
  121.         try{
  122.             args = new Class[1];
  123.             args[0] = com.sun.java.swing.table.TableModel.class ;
  124.             MethodDescriptor setModel = new MethodDescriptor(beanClass.getMethod("setModel", args));
  125.  
  126.             connections = new java.util.Vector();
  127.             connection = new ActionDescriptor("input", "TableModel", "",
  128.                                     "%name%.setModel(%arg%);",
  129.                                     conn.getString(JChartResourceBundle.JCHART_SET_MODEL_CONNNECTION_KEY));
  130.             connections.addElement(connection);
  131.  
  132.             setModel.setValue(MethodDescriptorAttributes.ACTION_ATTRIBUTE, connections);
  133.             md.addElement(setModel);
  134.         } catch (Exception e) { throw new Error("setModel:: " + e.toString()); }
  135.  
  136.         try{
  137.             args = new Class[1];
  138.             args[0] = java.lang.Integer.TYPE;
  139.             MethodDescriptor setStyle = new MethodDescriptor(beanClass.getMethod("setStyle", args));
  140.  
  141.             connections = new java.util.Vector();
  142.             connection = new ActionDescriptor("input", "int", "",
  143.                                     "%name%.setStyle(%arg%);",
  144.                                     conn.getString(JChartResourceBundle.JCHART_SET_STYLE_CONNNECTION_KEY));
  145.             connections.addElement(connection);
  146.  
  147.             setStyle.setValue(MethodDescriptorAttributes.ACTION_ATTRIBUTE, connections);
  148.             md.addElement(setStyle);
  149.         } catch (Exception e) { throw new Error("setStyle:: " + e.toString()); }
  150.  
  151.         try{
  152.             args = null;
  153.             MethodDescriptor getStyle = new MethodDescriptor(beanClass.getMethod("getStyle", args));
  154.  
  155.             connections = new java.util.Vector();
  156.             connection = new ActionDescriptor("output", "int", "",
  157.                                     "%name%.getStyle()",
  158.                                     conn.getString(JChartResourceBundle.JCHART_GET_STYLE_CONNNECTION_KEY));
  159.             connections.addElement(connection);
  160.  
  161.             getStyle.setValue(MethodDescriptorAttributes.ACTION_ATTRIBUTE, connections);
  162.             md.addElement(getStyle);
  163.         } catch (Exception e) { throw new Error("getStyle:: " + e.toString()); }
  164.  
  165.         try{
  166.             args = new Class[1];
  167.             args[0] = java.lang.String.class;
  168.             //args[0] = java.lang.Boolean.TYPE;
  169.             MethodDescriptor setTitle = new MethodDescriptor(beanClass.getMethod("setTitle", args));
  170.  
  171.             connections = new java.util.Vector();
  172.             connection = new ActionDescriptor("input", "String", "",
  173.                                     "%name%.setTitle(%arg%);",
  174.                                     conn.getString(JChartResourceBundle.JCHART_SET_TITLE_CONNNECTION_KEY));
  175.             connections.addElement(connection);
  176.  
  177.             setTitle.setValue(MethodDescriptorAttributes.ACTION_ATTRIBUTE, connections);
  178.             md.addElement(setTitle);
  179.         } catch (Exception e) { throw new Error("setTitle:: " + e.toString()); }
  180.  
  181.         try{
  182.             args = null;
  183.             MethodDescriptor getTitle = new MethodDescriptor(beanClass.getMethod("getTitle", args));
  184.  
  185.             connections = new java.util.Vector();
  186.             connection = new ActionDescriptor("output", "String", "",
  187.                                     "%name%.getTitle()",
  188.                                     conn.getString(JChartResourceBundle.JCHART_GET_TITLE_CONNNECTION_KEY));
  189.             connections.addElement(connection);
  190.  
  191.             getTitle.setValue(MethodDescriptorAttributes.ACTION_ATTRIBUTE, connections);
  192.             md.addElement(getTitle);
  193.         } catch (Exception e) { throw new Error("getTitle:: " + e.toString()); }
  194.  
  195.         try{
  196.             args = new Class[1];
  197.             args[0] = java.lang.Integer.TYPE;
  198.             MethodDescriptor setNumYTicks = new MethodDescriptor(beanClass.getMethod("setNumYTicks", args));
  199.  
  200.             connections = new java.util.Vector();
  201.             connection = new ActionDescriptor("input", "int", "",
  202.                                     "%name%.setNumYTicks(%arg%);",
  203.                                     conn.getString(JChartResourceBundle.JCHART_SET_NUMYTICKS_CONNNECTION_KEY));
  204.             connections.addElement(connection);
  205.  
  206.             setNumYTicks.setValue(MethodDescriptorAttributes.ACTION_ATTRIBUTE, connections);
  207.             md.addElement(setNumYTicks);
  208.         } catch (Exception e) { throw new Error("setNumYTicks:: " + e.toString()); }
  209.  
  210.         try{
  211.             args = null;
  212.             MethodDescriptor getNumYTicks = new MethodDescriptor(beanClass.getMethod("getNumYTicks", args));
  213.  
  214.             connections = new java.util.Vector();
  215.             connection = new ActionDescriptor("output", "int", "",
  216.                                     "%name%.getNumYTicks()",
  217.                                     conn.getString(JChartResourceBundle.JCHART_GET_NUMYTICKS_CONNNECTION_KEY));
  218.             connections.addElement(connection);
  219.  
  220.             getNumYTicks.setValue(MethodDescriptorAttributes.ACTION_ATTRIBUTE, connections);
  221.             md.addElement(getNumYTicks);
  222.         } catch (Exception e) { throw new Error("getNumYTicks:: " + e.toString()); }
  223.  
  224.         try{
  225.             args = null;
  226.             MethodDescriptor getNumSeries = new MethodDescriptor(beanClass.getMethod("getNumSeries", args));
  227.  
  228.             connections = new java.util.Vector();
  229.             connection = new ActionDescriptor("output", "int", "",
  230.                                     "%name%.getNumSeries()",
  231.                                     conn.getString(JChartResourceBundle.JCHART_GET_NUMSERIES_CONNNECTION_KEY));
  232.             connections.addElement(connection);
  233.  
  234.             getNumSeries.setValue(MethodDescriptorAttributes.ACTION_ATTRIBUTE, connections);
  235.             md.addElement(getNumSeries);
  236.         } catch (Exception e) { throw new Error("getNumSeries:: " + e.toString()); }
  237.  
  238.         try{
  239.             args = new Class[1];
  240.             args[0] = java.lang.Double.TYPE;
  241.             MethodDescriptor setYAxisMin = new MethodDescriptor(beanClass.getMethod("setYAxisMin", args));
  242.  
  243.             connections = new java.util.Vector();
  244.             connection = new ActionDescriptor("input", "double", "",
  245.                                     "%name%.setYAxisMin(%arg%);",
  246.                                     conn.getString(JChartResourceBundle.JCHART_SET_YAXISMIN_CONNNECTION_KEY));
  247.             connections.addElement(connection);
  248.  
  249.             setYAxisMin.setValue(MethodDescriptorAttributes.ACTION_ATTRIBUTE, connections);
  250.             md.addElement(setYAxisMin);
  251.         } catch (Exception e) { throw new Error("setYAxisMin:: " + e.toString()); }
  252.  
  253.         try{
  254.             args = null;
  255.             MethodDescriptor getYAxisMin = new MethodDescriptor(beanClass.getMethod("getYAxisMin", args));
  256.  
  257.             connections = new java.util.Vector();
  258.             connection = new ActionDescriptor("output", "double", "",
  259.                                     "%name%.getYAxisMin()",
  260.                                     conn.getString(JChartResourceBundle.JCHART_GET_YAXISMIN_CONNNECTION_KEY));
  261.             connections.addElement(connection);
  262.  
  263.             getYAxisMin.setValue(MethodDescriptorAttributes.ACTION_ATTRIBUTE, connections);
  264.             md.addElement(getYAxisMin);
  265.         } catch (Exception e) { throw new Error("getYAxisMin:: " + e.toString()); }
  266.  
  267.         try{
  268.             args = new Class[1];
  269.             args[0] = java.lang.Double.TYPE;
  270.             MethodDescriptor setYAxisMax = new MethodDescriptor(beanClass.getMethod("setYAxisMax", args));
  271.  
  272.             connections = new java.util.Vector();
  273.             connection = new ActionDescriptor("input", "double", "",
  274.                                     "%name%.setYAxisMax(%arg%);",
  275.                                     conn.getString(JChartResourceBundle.JCHART_SET_YAXISMAX_CONNNECTION_KEY));
  276.             connections.addElement(connection);
  277.  
  278.             setYAxisMax.setValue(MethodDescriptorAttributes.ACTION_ATTRIBUTE, connections);
  279.             md.addElement(setYAxisMax);
  280.         } catch (Exception e) { throw new Error("setYAxisMax:: " + e.toString()); }
  281.  
  282.         try{
  283.             args = null;
  284.             MethodDescriptor getYAxisMax = new MethodDescriptor(beanClass.getMethod("getYAxisMax", args));
  285.  
  286.             connections = new java.util.Vector();
  287.             connection = new ActionDescriptor("output", "double", "",
  288.                                     "%name%.getYAxisMax()",
  289.                                     conn.getString(JChartResourceBundle.JCHART_GET_YAXISMAX_CONNNECTION_KEY));
  290.             connections.addElement(connection);
  291.  
  292.             getYAxisMax.setValue(MethodDescriptorAttributes.ACTION_ATTRIBUTE, connections);
  293.             md.addElement(getYAxisMax);
  294.         } catch (Exception e) { throw new Error("getYAxisMax:: " + e.toString()); }
  295.  
  296.         MethodDescriptor[] rv = new MethodDescriptor[md.size()];
  297.         md.copyInto(rv);
  298.  
  299.         return rv;
  300.     }
  301.  
  302.     protected final static Class beanClass = JChart.class;
  303.     protected final static String m_WinHelpID = "0x6013D";
  304. }
  305.